from pages.LoginPage import LoginPage
from selenium.common.exceptions import StaleElementReferenceException
from selenium.webdriver.common.by import By
from time import sleep

class rmp_01(LoginPage):
    rtp_01 = (By.XPATH, '//span[contains(text(), "招聘跟踪")]/..')
    trtp_01 = (By.LINK_TEXT, '传统简历跟踪')
    query_01 = (By.XPATH, '//span[contains(text(), "查 询")]/..')
    phone = (By.ID,'phone')
    name = (By.ID,'name')
    priority_dj = ('css selector','[fill="currentColor"]')#优先级下拉框，角标12
    priority = ('class name','ant-select-dropdown-menu-item')#优先级下拉框元素，01234
    HR_Specialist = ('css selector','[fill="currentColor"]')#人事专员下拉框13
    HR_Specialist_dj = ('class name', 'ant-select-dropdown-menu-item')  # 人事专员下拉框元素5，6，7
    times = ('css selector','[placeholder="开始日期"]')#下次跟踪开始时间脚标0，分配开始时间脚标1
    times_dj = ('class name','ant-tag')#当前时间脚标0
    product_name = ('css selector','[fill="currentColor"]')#产品名下标16
    product_list = (By.XPATH, '//li[contains(text(), "全部")]')
    development = ('css selector','[fill="currentColor"]')#进展状况下标17
    development_last = (By.XPATH, '//li[contains(text(), "全部简历")]')
    query_02 = ('class name','ant-btn')#查询确定按钮，脚标3

    def __init__(self):
        super().__init__()
        self.login()
        self.find_ele(self.loc_recuitManage).click()
        self.find_ele(self.rtp_01).click()
        self.find_ele(self.trtp_01).click()

    def phone_query(self, Phone,Name):
        self.find_ele(self.query_01).click()
        self.find_ele(self.phone).send_keys(Phone)
        self.find_ele(self.name).send_keys(Name)
        self.find_eles(self.priority_dj)[12].click()
        self.find_eles(self.priority)[0].click()
        self.find_eles(self.HR_Specialist)[13].click()
        self.find_eles(self.HR_Specialist_dj)[6].click()
        self.find_eles(self.times)[0].click()
        self.find_eles(self.times_dj)[0].click()
        self.find_eles(self.product_name)[16].click()
        self.find_ele(self.product_list).click()
        self.find_eles(self.development)[17].click()
        self.find_ele(self.development_last).click()
        self.find_eles(self.times)[1].click()
        self.find_eles(self.query_02)[3].click()

        # try:
        #     assert city_name == self.find_ele(self).text, '添加失败'
        # except AssertionError:
        #     return False
        # else:
        #     return True
    #
    # def choose_city(self, city_name):
    #     loc_checkBox = (By.XPATH, self.loc_checkBox % city_name)
    #     self.find_ele(loc_checkBox).click()
    #
    # def edit_city(self, old_name, new_name):
    #     self.choose_city(old_name)
    #     self.find_ele(self.loc_editButton).click()
    #     self.find_ele(self.loc_cityName).clear()
    #     self.find_ele(self.loc_cityName).send_keys(new_name)
    #     self.find_ele(self.loc_confirmButton).click()
    #     try:
    #         assert new_name == self.find_ele(new_name).text, '编辑失败'
    #     except AssertionError:
    #         return False
    #     else:
    #         return True
    #
    # def delete_city(self, city_name):
    #     self.choose_city(city_name)
    #     self.find_ele(self.loc_delButton).click()
    #     self.find_ele(self.loc_alertButton).click()
    #     try:
    #         loc_checkBox = (By.XPATH, self.loc_checkBox % city_name)
    #         self.find_ele(loc_checkBox).click()
    #     except StaleElementReferenceException:
    #         return True
    #     else:
    #         return False


a = rmp_01()
a.phone_query(13551841756,'lisi2023',)